<?php
	header("Content-Type: text/html;charset=utf-8");

	session_start(); //开启session

	$servername = "localhost";
	$username = "root";
	$password = "456789";
	$dbname = "mysqlstudy";

	$conn = new mysqli($servername, $username, $password, $dbname);
	if($conn -> connect_error){
		die("连接失败:" . $conn -> connect_error);
	}
	mysqli_query($conn, "set names utf8");
	
	$uid = $_POST["uid"];   //前端传递的用户名
	$pwd = $_POST["pwd"];   //前端传递的密码

	$sql = "SELECT pwd FROM user WHERE uid='{$uid}' AND pwd='{$pwd}'";

	$result = $conn->query($sql);
	$result = $result->fetch_assoc();

	if($result){
		$_SESSION["uid"] = $uid;
		echo "OK";
	}else{
		echo "NO";
	}



?>